﻿#include "SetModelCmd.h"
#include "../util/JsonUtil.h"
#include "../util/HttpUtil.h"
#include "../util/SystemHelper.h"
#include "../util/TextUtil.h"
#include "../config/SystemConfig.h"

SetModelCmd::SetModelCmd()
{
}

SetModelCmd::~SetModelCmd()
{
}

bool SetModelCmd::Parse(std::string json)
{
	// 解析json
	JsonUtil jsonUtil;
	if (jsonUtil.Parse(json))
	{
		std::string id = jsonUtil.GetString("model.id", "");
		std::string name = jsonUtil.GetString("model.name", "");
		std::string description = jsonUtil.GetString("model.description", "");
		std::string url = jsonUtil.GetString("model.model", "");
		std::string cls = jsonUtil.GetString("model.cls", "");
		std::string normal = jsonUtil.GetString("model.normal", "");
		std::string alarm = jsonUtil.GetString("model.alarm", "");
		int enabled = jsonUtil.GetInt("model.enabled", 1);
		std::string createTime = jsonUtil.GetString("model.createTime", "");
		
		m_model.SetId(id);
		m_model.SetName(name);
		m_model.SetDescription(description);
		m_model.SetEnabled(enabled);
		m_model.SetNormal(normal);
		m_model.SetAlarm(alarm);
		m_model.SetCls(cls);
		return true;
	}
	return false;
}

ModelInfo SetModelCmd::GetModel()
{
	return m_model;
}